Socket
Socket
Sign inDemoInstall

node-tictoc

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-tictoc

Simple stopwatch timer for profiling operations


Version published
Weekly downloads
10
decreased by-16.67%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

tictoc

npm install node-tictoc

Wrapper around process.hrtime that lets you have a stack of timers with a simpler api and more useful output:

Usage

  var time = require('node-tictoc');

  time.tic();

  for(var i = 0; i < 1000; i++) {
    // do something
  }

  time.toc(); // prints the elapsed seconds and/or milliseconds

Or a recursive timing solution that takes advantage of the stack:

  function foo(n) {
    if (! n) return;

    time.tic();

    foo(n - 1);

    time.toc(); // prints the elapsed time in last-in-first-out (LIFO) order
  }

If you just want the time values:

  time.toct()

If you want the profiling string but don't want it console logged automatically:

  time.stoc();

Returns an object with the following values for the most recent timer (started with tic):

  • seconds
  • nanos
  • ms

Keywords

FAQs

Last updated on 14 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc